<template>
  <div id="edit">
    <div class="el_content">
      <el-row class="edit-title">
        <el-col :span="4">新增随访</el-col>
        <el-col :span="3" :offset="17" class="text-right">
          <el-button
            class="back"
            type="info"
            size="mini"
            plain
            icon="el-icon-arrow-left"
            @click="goBack"
          >返回</el-button>
        </el-col>
      </el-row>
      <el-form :model="info" :rules="rules" ref="info" label-width="130px" class="el_t_20">
        <el-form-item label="姓名：" prop="name">
          <el-row>
            <el-col :span="8">
              <el-autocomplete
                class="el_long"
                v-model="info.name"
                :fetch-suggestions="querySearch"
                suffix-icon="el-icon-search"
                placeholder="请输入患者姓名"
                @select="handleSelect"
              ></el-autocomplete>
            </el-col>
            <el-col :span="4">
              <el-button type="text" style="margin-left:20px;">查看详细病例》</el-button>
            </el-col>
          </el-row>
        </el-form-item>
        <el-form-item label="门诊号">
          <el-row>
            <el-col :span="8">
              <el-autocomplete
                class="el_long"
                v-model="info.name"
                :fetch-suggestions="querySearch"
                suffix-icon="el-icon-search"
                placeholder="请输入患者门诊号"
                @select="handleSelect"
              ></el-autocomplete>
            </el-col>
          </el-row>
        </el-form-item>
        <el-form-item label="性别：" prop="sex">
          <el-row>
            <el-col :span="24">
              <el-radio-group v-model="info.sex">
                <el-radio :label="'男'">男</el-radio>
                <el-radio :label="'女'">女</el-radio>
                <el-radio :label="'不详'">不详</el-radio>
              </el-radio-group>
            </el-col>
          </el-row>
        </el-form-item>
        <el-form-item label="电话：" prop="name">
          <el-row>
            <el-col :span="8">
              <el-input type="text" placeholder="请输入患者联系电话，多个请用逗号隔开"></el-input>
            </el-col>
          </el-row>
        </el-form-item>
        <el-form-item label="就诊时间：">
          <el-row>
            <el-col :span="8">
              <el-date-picker
                class="el_long"
                v-model="info.name"
                type="date"
                placeholder="请选择患者就诊时间"
              ></el-date-picker>
            </el-col>
          </el-row>
        </el-form-item>
        <el-row class="edit-title">
          <el-col :span="4">随访设置</el-col>
        </el-row>
        <el-form-item label="计划随访日期：" class="el_t_20" prop="name">
          <el-row>
            <el-col :span="8">
              <el-date-picker
                class="el_long"
                v-model="info.name"
                type="date"
                placeholder="请选择计划随访日期"
              ></el-date-picker>
            </el-col>
          </el-row>
        </el-form-item>
        <el-form-item label="计划随访内容：" prop="name">
          <el-row>
            <el-col :span="24">
              <el-input type="text" placeholder="请输入预期随访内容"></el-input>
            </el-col>
          </el-row>
        </el-form-item>
        <el-form-item label="随访类型：" prop="name">
          <el-radio-group v-model="info.radio">
            <el-radio :label="1">患者满意度随访</el-radio>
            <el-radio :label="2">诊后常规随访</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="随访方式：" prop="name">
          <el-radio-group v-model="info.radio">
            <el-radio :label="1">电话</el-radio>
            <el-radio :label="2">微信</el-radio>
            <el-radio :label="2">其他</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-form>
      <el-row class="footer-fixed">
        <el-col :span="24" class="text-right">
          <el-button type="primary" plain @click="deleteMsg">取 消</el-button>
          <el-button type="warning" @click="nextInfo">保存并新增下次</el-button>
          <el-button type="primary" @click="submitInfo('info')">保 存</el-button>
        </el-col>
      </el-row>
    </div>
  </div>
</template>
<script>
export default {
  name: "edit",
  data() {
    return {
      info: {
        name: "",
        radio: 1,
        sex: ""
      },
      rules: {
        name: [
          { required: true, message: "医嘱名称不能为空", trigger: "blur" }
        ],
        radio: [
          { required: true, message: "请选择所属分类", trigger: "change" }
        ]
      },
      restaurants: [
        { value: "三全鲜食（北新泾店）", address: "长宁区新渔路144号" },
        {
          value: "Hot honey 首尔炸鸡（仙霞路）",
          address: "上海市长宁区淞虹路661号"
        },
        {
          value: "新旺角茶餐厅",
          address: "上海市普陀区真北路988号创邑金沙谷6号楼113"
        },
        { value: "泷千家(天山西路店)", address: "天山西路438号" }
      ]
    };
  },
  methods: {
    nextInfo() {
      this.$router.push({ name: "followNext" });
    },
    querySearch(queryString, cb) {
      var restaurants = this.restaurants;
      var results = queryString
        ? restaurants.filter(this.createFilter(queryString))
        : restaurants;
      // 调用 callback 返回建议列表的数据
      cb(results);
    },
    handleSelect(item) {
      console.log(item);
    },
    submitInfo(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          alert("验证通过！");
        } else {
          return false;
        }
      });
    },
    goBack() {
      this.$router.go(-1);
    },
    deleteMsg(data) {
      this.$confirm("确定删除该条记录？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "点错了",
        type: "warning"
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "取消成功!"
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消"
          });
        });
    }
  }
};
</script>
<style scoped>
.el_content {
  width: 100%;
  height: calc(100vh - 150px);
  background: #ffffff;
  padding: 20px;
}
.edit-title {
  padding-bottom: 10px;
  border-bottom: 1px solid #e4e4e4;
  color: #006835;
  font-weight: 700;
}
</style>


